Skip to content

wrap yaml into main to avoid it auto-running on validate through the import#163

Closed
CIGbalance wants to merge 4 commits intomainfrom
fix/accidental_html_update
Closed

wrap yaml into main to avoid it auto-running on validate through the import#163
CIGbalance wants to merge 4 commits intomainfrom
fix/accidental_html_update

Conversation

@CIGbalance
Copy link
Copy Markdown
Collaborator

@CIGbalance CIGbalance commented Apr 21, 2026

This pull request refactors the yaml_to_html.py script to improve code structure, readability, and maintainability. The main changes involve moving data loading and processing into a __main__ guard, reformatting code for clarity, and making minor improvements to table generation.

Code organization and structure:

  • Moved the main script logic (data loading, column selection, and table generation) under the if __name__ == "__main__": block to prevent accidental execution when the module is imported.
  • Reformatted code for better readability, including consistent indentation and line breaks, especially in the linkify_cell function and table generation. [1] [2]

Data loading and processing:

  • Relocated the data loading and column selection logic into the main guard, making the script's execution flow clearer and more modular. [1] [2]

Copilot AI review requested due to automatic review settings April 21, 2026 10:34
@CIGbalance CIGbalance changed the title wrap yaml into main to avoid it auto-running on validate through the … wrap yaml into main to avoid it auto-running on validate through the import Apr 21, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents yaml_to_html.py from executing its YAML→HTML generation logic on import (e.g., when utils/validate_yaml.py imports default_columns), by moving runtime behavior behind a __main__ guard.

Changes:

  • Wrapped YAML loading, table generation, and HTML file writing in if __name__ == "__main__":.
  • Moved default_columns to module scope so it remains importable without triggering generation.
  • Minor formatting adjustments (e.g., multiline href assignment, to_html call formatting).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread yaml_to_html.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@CIGbalance CIGbalance requested a review from kvdblom April 21, 2026 10:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread yaml_to_html.py
Comment thread yaml_to_html.py
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread yaml_to_html.py
data = pd.json_normalize(yaml.safe_load(yaml_input))


if all_columns is False:
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within this block, if all_columns is False: is a non-idiomatic boolean check and reduces readability. Prefer if not all_columns: (or just if all_columns: where appropriate) for consistency with typical Python style.

Suggested change
if all_columns is False:
if not all_columns:

Copilot uses AI. Check for mistakes.
Comment thread yaml_to_html.py
Comment on lines +58 to +59


Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are multiple consecutive blank lines/whitespace-only lines after loading the YAML (between the with open(...) block and the next if), which adds noise in the main flow. Please remove the extra blank lines to keep the script compact and consistent with the surrounding style.

Suggested change

Copilot uses AI. Check for mistakes.
@CIGbalance
Copy link
Copy Markdown
Collaborator Author

Change will be added by @Dvermetten somewhere else

@CIGbalance CIGbalance closed this Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants